import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { WinstonModule } from 'nest-winston';
// import winstonLogger from './core/logger';
import { HttpExecptionFilter } from './filters/http-execption.filter';
import { WINSTON_MODULE_NEST_PROVIDER } from 'nest-winston';
import { AllExceptionFilter } from './filters/all-exception.filter';
import { ValidationPipe } from '@nestjs/common';

async function bootstrap() {
  const app = await NestFactory.create(AppModule, {
    // logger: WinstonModule.createLogger({
    //   instance: winstonLogger
    // })
  });

  app.useLogger(app.get(WINSTON_MODULE_NEST_PROVIDER));
  const httpAdapter = app.getHttpAdapter()
  app.useGlobalFilters(new AllExceptionFilter(httpAdapter))
  app.useGlobalPipes(new ValidationPipe({
    // 去除类中没有的字段
    // whitelist: true
  }))
  // app.useGlobalPipes(new ValidationPipe())
  await app.listen(process.env.PORT ?? 3000);
}
bootstrap();
